<?php
            


/**
 * Desc:
 * Time: 2021/3/29 5:12 下午
 */
class Redpackage_Page extends PluginWebPage {
    function main(){
        $method = 'redpackage_main';
        global $_G,$_P,$_S,$_C;
        $system = $_S;
        $config = $_C;
        $themeid = $_P['themeid'];
        $page_index = max(1,intval($_P['page']));
        $page_size = 50;
        $page_start = ($page_index-1)*$page_size;


        $page_total = LotteryModel::getRedPackageList($themeid,0,0,0,true);
        $list = LotteryModel::getRedPackageList($themeid,0,$page_start,$page_size);
        $total = $page_total;

        $pager = pagination($page_total,$page_index,$page_size);
        $return_clicent = get_defined_vars();
return $this->view('/lottery/red_envelope/main', $return_clicent);
    }

    function search()
    {
        $method = 'redpackage_main';
        global $_G,$_P,$_S,$_C;
        $system = $_S;
        $config = $_C;
        $themeid = $_P['themeid'];
        $page_index = max(1,intval($_P['page']));
        $page_size = 50;
        $page_start = ($page_index-1)*$page_size;

        if (empty($_P['createtime']['start'])){
            $start_day =db_fetchcolumn ( 'SELECT min(addtime) FROM ' . tablename ( t_fans ) );
            $start_day =  date('Y-m-d',$start_day);
        }else{
            $start_day =  $_P['createtime']['start'];
        }
        $end_day = empty($_P['createtime']['end']) ? date('Y-m-d',TIMESTAMP): $_P['createtime']['end'] ;
        $search_data = isset($_P['search_data'])?$_P['search_data']:'';
        if ($search_data){
            $search_data = '%'.$search_data.'%';
        }
        $total = LotteryModel::searchRedPackage($themeid,$search_data,0,0,$start_day,$end_day,true);

        $list = LotteryModel::searchRedPackage($themeid,$search_data,$page_start,$page_size,$start_day,$end_day);
        $page_total = $total;

        $pager = pagination($page_total,$page_index,$page_size);
        $return_clicent = get_defined_vars();
return $this->view('/lottery/red_envelope/main', $return_clicent);
    }
}